const Mock = require("mockjs");
const Random = Mock.Random;

// 账号列表
const accountList = function () {
  const list = [];
  for (let i = 0; i < 20; i++) {
    const obj = {
      "accountId": Random.id(),
      "accountName": Random.first(),
      "realName": Random.cname(),
      "phone": "15000000000",
      "roleId": Random.id(),
      "roleName": Random.csentence(3, 8)
    };
    list.push(obj);
  }
  return list;
};
Mock.mock("/mock/getAccountList", accountList);

// 角色列表
const roleList = function () {
  const list = [];
  for (let i = 0; i < 20; i++) {
    const obj = {
      "roleId": Random.id(),
      "roleName": Random.csentence(3, 8),
      "description": Random.csentence(10, 30)
    };
    list.push(obj);
  }
  return list;
};
Mock.mock("/mock/getRoleList", roleList);

// 角色权限树
const rolePermission = function () {
  const data = [
    {
      "menuCode": "Equity", "menuName": "权益中心", "menuOrder": 1,
      "children": [
        { "menuCode": "Member", "menuName": "会员列表", "menuOrder": 1 },
        { "menuCode": "Record", "menuName": "记录表", "menuOrder": 2 },
        { "menuCode": "DataManage", "menuName": "数据管理", "menuOrder": 3 },
        { "menuCode": "ServiceConfigure", "menuName": "服务配置", "menuOrder": 4 }
      ]
    },
    {
      "menuCode": "Account", "menuName": "账号管理", "menuOrder": 2,
      "children": [
        { "menuCode": "UserList", "menuName": "账号列表", "menuOrder": 1 },
        { "menuCode": "RoleList", "menuName": "角色列表", "menuOrder": 2 }
      ]
    },
    {
      "menuCode": "Dictionary", "menuName": "字典管理", "menuOrder": 3,
      "children": [
        { "menuCode": "DictionaryIndex", "menuName": "字典管理", "menuOrder": 1 }
      ]
    }
  ];
  return data;
};
Mock.mock("/mock/getRolePermission", rolePermission);

// 单位列表
const companyList = function () {
  const list = [];
  for (let i = 0; i < 20; i++) {
    const obj = {
      "companyNo": Random.id(),
      "companyName": Random.cname()
    };
    list.push(obj);
  }
  return list;
};
Mock.mock("/mock/getCompanyList", companyList);
